package com.jy.appmarket.cards;

import it.gmariotti.cardslib.library.internal.Card;
import android.content.Context;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.google.gson.JsonElement;
import com.jy.app.market.idata.data.Apk;
import com.jy.appmarket.R;
import com.ms.square.android.expandabletextview.ExpandableTextView;

/**
 * 类说明：
 * 
 * @author Baker.li
 * @date 2015年8月21日
 * @version 1.0
 */

public class AppDetailIntroUICard extends Card {
	private Apk mApk;

	public AppDetailIntroUICard(Context context, Apk apk) {
		super(context, R.layout.appdetail_intro_card_layout);
		mApk = apk;
	}

	@Override
	public void setupInnerViewElements(ViewGroup parent, View view) {
		if (mApk == null) {
			return;
		}
		TextView version = parent.findViewById(R.id.appdetail_intro_version_name);
		TextView source = parent.findViewById(R.id.appdetail_intro_source);
		TextView developer = parent.findViewById(R.id.appdetail_intro_developer);
		ExpandableTextView exp = parent.findViewById(R.id.expand_text_view);
		version.setText(getContext().getString(R.string.version) + "：" + mApk.getVersionName());
		source.setText(getContext().getString(R.string.source) + "："
				+ mApk.getDownloadUrl().getMarket());
		String dev = getContext().getString(R.string.unknown);
		if (mApk.getDeveloper() != null) {
			JsonElement e = mApk.getDeveloper().get("name");
			if (e != null && !e.isJsonNull()) {
				dev = e.getAsString();
			}
		}
		developer.setText(getContext().getString(R.string.developer) + "：" + dev);
		exp.setText(Html.fromHtml(mApk.getDescription()));
	}

	@Override
	public int getType() {
		return 6;
	}
	
	@Override
	public int getMarginTop(){
		return 0; //返回0，则在顶部没有空隙
	}

}